package com.coldchain.admin.resoure.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.coldchain.common.vo.MenuVo;
import com.coldchain.admin.resoure.entity.Menu;
import com.coldchain.admin.resoure.mapper.MenuMapper;
import com.coldchain.admin.resoure.service.IMenuService;
import com.coldchain.common.util.TreeUtil;
import com.fangliai.core.context.BaseContextHandler;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单 服务实现类
 * </p>
 *
 * @author fangliai
 * @since 2018-08-28
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Override
    public List<MenuVo> findMenusBySysmod(String sysmodel) {
        List<MenuVo> menuVos=baseMapper.findMenuVoBySysmod(sysmodel);
        menuVos=TreeUtil.buildByRecursive(menuVos,0);
        return menuVos;
    }



    //TODO 需要实现权限控制
    @Override
    public List<MenuVo> getCurrentUserMenu() {
        List<MenuVo> menus=baseMapper.findMenuVoBySysmod(BaseContextHandler.getSysModl());
        TreeUtil.bulid(menus,0,null);
        return menus;
    }
}
